package com.estock.platform.task;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.estock.common.util.CommonUtil;
import com.estock.platform.manager.DBManager;
import com.estock.platform.task.support.ESJob;

/**
 * @author richard
 *
 */
@Component
public class LastTransDayUpdater extends ESJob {
	
	private static Logger logger = Logger.getLogger(LastTransDayUpdater.class);

	@Override
	protected void executeJob() {
		logger.info("start executing job: LastTransDayUpdater at " + new Date());
		try {
			DBManager.getInstance().updateLastTransday();
		} catch (Exception e) {
			logger.info("error executing job: LastTransDayUpdater at " + new Date());
			System.out.println("error executing job: LastTransDayUpdater at " + new Date());
			if (!CommonUtil.isUnitTest) {
				errorTaskRun();
			}
		}
		logger.info("finished executing job: LastTransDayUpdater at " + new Date());
		System.out.println("finished executing job: LastTransDayUpdater at " + new Date());
	}
	
	public static void main(String[] args) {
		CommonUtil.isUnitTest = true;
		new LastTransDayUpdater().executeJob();
	}

}
